//
//  ZWNewPropertyCell.m
//  NewProject
//
//  Created by tongtong on 2018/5/18.
//  Copyright © 2018年 chenIos. All rights reserved.
//

#import "ZWNewPropertyCell.h"
@interface ZWNewPropertyCell()
@property (nonatomic,strong) UIImageView *imag;//图标
@property (nonatomic,strong) UILabel *contentLabel;//标题
@property (nonatomic,strong) UILabel *describLabel;//说明
@property (nonatomic,strong) UILabel *keyLabel;//密钥
@property (nonatomic,strong) UIView *lineView;//分割线
//@property (nonatomic,strong) UISwitch *switchBtn;
@end
@implementation ZWNewPropertyCell
#pragma mark - init
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview];
    }
    return self;
}

#pragma mark - add subviews
- (void)addSubview {
    [self addSubview:self.imag];
    [self addSubview:self.contentLabel];
    [self addSubview:self.describLabel];
//    [self addSubview:self.keyLabel];
    [self addSubview:self.lineView];
//    [self addSubview:self.switchBtn];
    [self layoutSubviews];
}
-(void)switchIsChanged:(UISwitch *)swith{
    if ([swith isOn]){
        
        if(self.delegate && [self.delegate respondsToSelector:@selector(switchToOn:)]){
            [self.delegate switchToOn:YES];
        }
    }else{
        if(self.delegate && [self.delegate respondsToSelector:@selector(switchToOn:)]){
            [self.delegate switchToOn:NO];
        }

    }
}
#pragma mark - layout subviews
- (void)layoutSubviews {
    ZWWeakSelf;
    [_imag mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(@Scare_Width(15));
        make.centerY.mas_equalTo(weakSelf.mas_centerY);
        make.left.equalTo(@Scare_Width(20));
        make.size.mas_equalTo(CGSizeMake(Scare_Width(38), Scare_Width(38)));
    }];
    [_contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.imag.mas_top).mas_offset(0);
        make.left.equalTo(weakSelf.imag.mas_right).offset(Scare_Width(18));
        make.size.mas_equalTo(CGSizeMake(Scare_Width(80), Scare_Width(20)));
    }];
    [_describLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(weakSelf.imag.mas_bottom);
//        make.centerY.mas_equalTo(weakSelf.mas_centerY);
         make.left.equalTo(weakSelf.contentLabel.mas_left);
        make.size.mas_equalTo(CGSizeMake(Scare_Width(120), Scare_Width(15)));

    }];
    
//    [_keyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.top.equalTo(weakSelf.describLabel.mas_bottom).offset(Scare_Width(0));
//        make.left.equalTo(weakSelf.contentLabel.mas_left);
//        make.size.mas_equalTo(CGSizeMake(Scare_Width(120), Scare_Width(15)));
//
//    }];

    [_lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf.mas_bottom).offset(-Scare_Width(0.5));
        make.left.equalTo(weakSelf.mas_left);
        make.size.mas_equalTo(CGSizeMake(SCREEN_W, Scare_Width(0.5)));
    }];
    
    
}
#pragma mark --set---
- (UIImageView *)imag {
    if (!_imag) {
        _imag = [[UIImageView alloc] init];
        _imag.image = [[UIImage imageNamed:@"pkc_coin"] imageWithRenderingMode:(UIImageRenderingModeAlwaysOriginal)];
        _imag.contentMode = UIViewContentModeScaleAspectFill;
        _imag.layer.cornerRadius = Scare_Width(19);
        _imag.clipsToBounds = YES;
    }
    return _imag;
}
- (UILabel *)contentLabel {
    if (!_contentLabel) {
        _contentLabel = [[UILabel alloc] init];
        _contentLabel.font = H_Medium2;
        _contentLabel.textColor = COLOR_DARK_GRAY;
        _contentLabel.text = @"WE";
    }
    return _contentLabel;
}
- (UILabel *)describLabel {
    if (!_describLabel) {
        _describLabel = [[UILabel alloc] init];
        _describLabel.textColor = [UIColor colorWithHexString:@"#707275"];
        _describLabel.font = H_Medium6;
        _describLabel.text= @"WE coins";
    }
    return _describLabel;
}
- (UILabel *)keyLabel {
    if (!_keyLabel) {
        _keyLabel = [[UILabel alloc] init];
        _keyLabel.textColor = [UIColor colorWithHexString:@"b0b7cb"];
        _keyLabel.font = H_Medium7;
        _keyLabel.text = @"==$$1000";
    }
    return _keyLabel;
}
-(UIView *)lineView{
    if(!_lineView){
        _lineView = [[UIView alloc]init];
        _lineView.backgroundColor = COLOR_LIGHT_GRAY;
    }
    return _lineView;
}
//-(UISwitch *)switchBtn{
//    if(!_switchBtn){
//        _switchBtn = [[UISwitch alloc]init];
//        _switchBtn.on = YES;
//        [_switchBtn setOnImage:[UIImage imageNamed:@"open"]];
//        [_switchBtn setOffImage:[UIImage imageNamed:@"close"]];
//        [_switchBtn addTarget:self action:@selector(switchIsChanged:) forControlEvents:UIControlEventValueChanged];
//
//    }
//    return _switchBtn;
//}

@end
